<?php
/* -------------------------------------------------------------------------------------
* 	fork by itDOT Media - dirk mueller
* 	http://www.itdotmedia.de
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */
function array_sort_by_key(&$array, $fld, $order = 'ASC') {
  $testArray = array_values($array); 
    $testArray = $testArray[0];

  if (is_numeric($testArray[$fld]))
    $comparer = "return ".($order === 'DESC' ? -1 : 1). "*(\$a['$fld']-\$b['$fld']);";
  else
    $comparer = "return ".($order === 'DESC' ? -1 : 1). "*strcmp(\$a['$fld'],\$b['$fld']);";

  usort($array, create_function('$a,$b', $comparer));
}